n, m = map(int, input().split())
t = [0] * (m)
a = [0] * (n)
b = [0] * (n)
ans = [0] * n

t[0 : m] = list(map(int, input().split()))
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))

for i in range(n):
    for j in range(m):
        if a[i] <= t[j] <= b[i]:
            ans[i] += 1

print(*ans, sep = '\n')